<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<title>历史记录</title>
<style type="text/css">
</style>
</head>
<script type="text/javascript">
 $(function() {
 	initView();
});

function queryForm() {
	$("#ksTable").datagrid("reload");
}

function initView()
{
	initDatagrid();
	/**确认按钮*/
	$("#enter").on("click", function(){
		var rows = $("#ksTable").datagrid("getSelections");
		if(validateKs(rows)){
			/**封装科室信息*/
			var res = {};
			var ksdm = "";
			var ksmc = "";
			$(rows).each(function(index, item){
				ksdm += item["KSDM"]+",";
				ksmc += item["KSMC"]+",";
			});
			res["KSDM"] = ksdm.substr(0, ksdm.length-1);
			res["KSMC"] = ksmc.substr(0, ksmc.length-1);
			StoreCache.setCache("QYSQ_KSXX", res);
			parent.layer.closeAll("iframe");
		}
	});
	/**关闭按钮*/	
	$("#close").on("click", function(){
		parent.layer.closeAll("iframe");
	});
}

function initDatagrid(){
	/**科室缓存*/
	var YLTID = StoreCache.removeCache("QYLB_DETAIL_YLTID");
	//序号、机构名称、所属区域、类型、等级、经营性质、签约有效期、签约周期、操作、操作时间、操作机构、备注
	var opt = {
				idField : "GLID",
				uniqueId : "GLID",
				striped : true,
				columns : [ [ 
				{
					field : "YLJGMC",
					width : 150,
					align : "center",
					title : "机构名称"
				}, {
					field : "XZQHMC",
					width : 80,
					align : "center",
					title : "所属区域"
				}, {
					field : "WSJGLBMC",
					width : 80,
					align : "center",
					title : "类型"
				}, {
					field : "YYDJMC",
					width : 80,
					align : "center",
					title : "等级"
				}, {
					field : "JGFLGLMC",
					width : 120,
					align : "center",
					title : "经营性质"
				}, {
					field : "QYYXQMC",
					width : 70,
					align : "center",
					title : "签约有效期"
				}, {
					field : "qyzq",
					width : 150,
					align : "center",
					title : "签约周期",
					formatter : function(value, row, index){
						return "<span title='"+row["QYSJ"]+"至"+row["DQSJ"]+"'>"+row["QYSJ"]+"至"+row["DQSJ"]+"</span>";
					}
				}, {
					field : "cz",
					width : 70,
					align : "center",
					title : "操作",
					formatter : function(value, row, index){
						if(row["QYZT"]=="05"){
							return "解约";
						}else{
							return "自然到期";
						}
					}
				}, {
					field : "czsj",
					width : 80,
					align : "center",
					title : "操作时间",
					formatter : function(value, row, index){
						if(row["QYZT"]=="05"){
							return row["FQJYSJ"]
						}
					}
				}, {
					field : "czjg",
					width : 150,
					align : "center",
					title : "操作机构",
					formatter : function(value, row, index){
						if(row["QYZT"]=="05"){
							return "<span title='"+row["JYFQJGMC"]+"'>"+row["JYFQJGMC"]+"</span>";
						}
					}
				}, {
					field : "bz",
					width : 150,
					align : "center",
					title : "备注",
					formatter : function(value, row, index){
						if(row["QYZT"]=="05"){
							return "<span title='"+row["JYYYMC"]+"'>"+row["JYYYMC"]+"</span>";
						}
					}
				} ] ],
				pagination : true,
				pageNumber : 1,
				pageSize : 10,
				fit : true,
				fitColumns : true,
				singleSelect : false,
				rownumbers : true,
				method : "post",
				url : "queryLsDetail.service",
				onBeforeLoad : function(params)//加载之前回调 获取查询条件
				{
					params["YLTID"] = YLTID;
					params["JLZT"] = "0";
					return params;
				}
			};
	/**加载科室*/
	$("#ksTable").datagrid(opt);
}

/**查询按钮*/
function btnQueryHandler(){
	queryDatagrid();
}

/**刷新datagrid*/
function queryDatagrid(){
	$("#ksTable").datagrid("reload");
}

/**校验是否选择科室*/
function validateKs(rows){
	var flag = false;
	if(rows.lengt > 0){
		$.QuickAlert.alertFail({
			content : "请选择科室！",
		});
	}else{
		flag = true;
	}
	return flag;
}
</script>

<body>
<div class="easyui-layout" fit="true" style="width: 100%;">
	<div region="north" style="border: none; overflow: hidden;">
	<h4 class="h4-title" style="font-size: 18px;">
		历史记录
	</h4>
	</div>
	<div region="center" style="border: none;overflow: hidden;">
	<div class="easyui-layout" style="width:100%;border: none;height: 400px;" fit="true">
		<!-- <div region="north" style="border: none;overflow: hidden;">
			<form id="queryForm"></form>
			<div id="dgFormToolbar" style="background: white;">
				<table class="form-table" style="">
					<tr>
						<td class="td-text">科室名称：</td>
						<td class="td-content">
							<input id="KSMC" type="text" placeholder="科室名称">
						</td>
						<td class="td-text">
							<button class="btn btn-default" type="button"
							onclick="btnQueryHandler()">查询</button>
						</td>
					</tr>
				</table>
			</div>
		</div> -->
		<div region="center" style="border: none;height: 300px">
			<table id="ksTable">
			</table> 
		</div>
	</div>
	</div>
	<div region="south" style="border: none;">
		<div style="float:right;height: 30px;margin-right: 10px;">
			<button type="button" id="enter">确认</button>
			&nbsp;
			<button type="button" id="close">关闭</button>
		</div>
	</div>
</div>
</body>
</html>



